/*package com.example.utils;

import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

*//**
 * @author: Cherry
 * @create: 2021-09-17 12:51
 * @description: 日志打印
 *//*
//AOP切面 ：多个切面时，@Order(i)注解来标识切面的优先级。i的值越小，优先级越高
@Order(-5)
@Aspect
@Component
@Slf4j
public class InterceptorConfig {

    @Pointcut("execution(public * com.example.*(..))")
    public void log(){}


    //统计请求的处理时间
    ThreadLocal<Long> startTime = new ThreadLocal<>();

    @Before("log()")
    public void doBefore(JoinPoint joinPoint) throws Throwable{
        startTime.set(System.currentTimeMillis());
        //接收到请求，记录请求内容
        ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        javax.servlet.http.HttpServletRequest request = attributes.getRequest();
        String remoteHost = request.getRemoteHost();

        //记录请求的内容
        log.debug("Aspect_URL:"+request.getRequestURL().toString());
        log.debug("Aspect_Method:"+request.getMethod());
        log.debug("Aspect_ip:"+remoteHost);
    }

    @AfterReturning(returning = "ret" , pointcut = "log()")
    public void doAfterReturning(Object ret){
        //处理完请求后，返回内容
        log.debug("方法返回值:"+ JSON.toJSONString(ret) +",方法执行时间:"+ (System.currentTimeMillis() - startTime.get()));
    }*/



